#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
using namespace std;
const int N = 1e6+10;
typedef long long ll;
int n,m;
int tree[N];
ll logTree(int high)
{
	int l=-1,r=n;
	while(l+1<r)
	{
		int mid=(l+r)/2;
		if(tree[mid]<high) l=mid;
		else r=mid;
	}
	ll sum=0;
	for(int i=r;i<n;i++)
	{
		sum+= tree[i]-high;
	}
	return sum;
}
signed main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&tree[i]);
	}
	sort(tree,tree+n);
	ll l=-1,r=tree[n-1];
	while(l+1<r)
	{
		ll mid=(l+r)/2;
		if(logTree(mid)>=m) l=mid;
		else r=mid;
	}
	cout<<l;
	
    return 0;
}
